﻿eventModule.controller("skillController", function ($scope, $route, $routeParams, $location, EventService) {
    EventService.getSkills($routeParams.id).then(function (skills) {
        $scope.skills = skills;
        $scope.model = {
            vacancy_id: $routeParams.id
        };
    }, function ()
    { alert('Error Occured.') });


    $scope.add = function (model) {
        EventService.addSkill(model).then(function () {
            $route.reload();
        }, function ()
        { alert('Skill already added.') });
    };

    $scope.delete = function (skill) {
        var vacancy_id = skill.vacancy_id;
        var skill_id = skill.skill_id;
        EventService.deleteSkill(vacancy_id, skill_id).then(function () {
            $route.reload();
        }, function () { alert('Error occured.') });
    };

});